package com.wyx.suanfa;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class letterCombinations {
    //给定一个仅包含数字 2-9 的字符串，返回所有它能表示的字母组合。答案可以按 任意顺序 返回。
    //
    //给出数字到字母的映射如下（与电话按键相同）。注意 1 不对应任何字母。
    public static void main(String[] args) {



    }
}
/*
* class Solution {
    public List<String> letterCombinations(String digits) {
        List<String> ret = new ArrayList<>();
        if(digits.length() == 0){
            return ret;
        }
        Map<Character, String> phoneMap = new HashMap<Character, String>() {{
            put('2', "abc");
            put('3', "def");
            put('4', "ghi");
            put('5', "jkl");
            put('6', "mno");
            put('7', "pqrs");
            put('8', "tuv");
            put('9', "wxyz");
        }};
        //回溯
        backtrace(digits,ret,phoneMap,0,new StringBuffer());
        return ret;

    }

    private void backtrace(String digits,List<String> ret,Map<Character, String> phoneMap,
    int index,StringBuffer sb){
        if(index == digits.length()){
            ret.add(sb.toString());
            return;
        }
        Character curChar = digits.charAt(index);
        String curString = phoneMap.get(curChar);
        int strLen = curString.length();
        for(int i = 0;i<strLen;i++){
            sb.append(curString.charAt(i));
            backtrace(digits,ret,phoneMap,index + 1,sb);
            sb.deleteCharAt(index);
        }


    }
}*/